﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Oracle;
using System.Data.Common;
using WeifenLuo.WinFormsUI.Docking;

namespace GgCarControl
{
    public partial class CAR_ST : DockContent
    {
        public CAR_ST()
        {
            InitializeComponent();
        }
        public static Database db =
            new OracleDatabase("Data Source=DG;User ID=dgrfid;Password=dgrfid;Unicode=True;Load Balance Timeout=1000");
        private void button1_Click(object sender, EventArgs e)
        {
            //Begin time value
            string date_time_begin = this.dateTimePicker1.Value.ToString();
            int ind = date_time_begin.IndexOf(" ");
            string date_value_begin = date_time_begin.Substring(0, ind);
            //End time value
            string date_time_end = this.dateTimePicker2.Value.ToString();
            int ind2 = date_time_end.IndexOf(" ");
            string date_value_end = date_time_end.Substring(0, ind2);
            //Car NO value
            string car_no = this.txt_car_no.Text.ToString();

            string sql = "select logintime as 登记时间 ,truckno as  车号,stackname as 垛名,cargoname as 货名,shipper_name as 船名,yard as 地点,pieces as 件数,cardadd as 发卡地点 from TRUCK_CARGO_LOGIN where logintime<=to_date('" + date_value_end + "','yyyy-mm-dd') and logintime>=to_date('" + date_value_begin + "','yyyy-mm-dd') and TRUCKNO like '%" + car_no + "%' and ioyardid='0'";
            //string sql = "select logintime as 登记时间 ,truckno as  车号,stackname as 垛名,cargoname as 货名,shipper_name as 船名,yard as 地点,pieces as 件数,cardadd as 发卡地点 from TRUCK_LOGIN where truckno = '鲁L32953'";
            DataTable dt = db.ExecuteDataSet(db.GetSqlStringCommand(sql.ToString())).Tables[0];

            this.dataGridView1.AutoGenerateColumns = true;
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.DataSource = dt;
        }
    }
}
